package dog.black.com.blackdog;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.View;

import com.orhanobut.logger.Logger;
import com.tencent.smtt.sdk.QbSdk;

import dog.black.com.blackdog.utils.AppShare;
import dog.black.com.blackdog.videoPage.VideoViewActivity;

/**
 * Created by feq on 2017/3/12.
 */

public class GuideActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //添加动态权限
        //            if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
        //        }
        initX5();

        if (AppShare.getInstence(App.getInstance()).getBoolean("isFirst", true)) {
            setContentView(R.layout.activity_guide);
            findViewById(R.id.bt_next).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    AppShare.getInstence(App.getInstance()).putBooleanValue("isFirst", false);
                    goMain();
                }
            });

        } else {
            goMain();
        }


    }

    private void goMain() {
        Intent intent = new Intent();
        intent.setClass(GuideActivity.this, VideoViewActivity.class);
        startActivity(intent);
        finish();
    }

    /**
     * 初始化h5内核
     */
    private void initX5() {
        QbSdk.initX5Environment(this, new QbSdk.PreInitCallback() {
            @Override
            public void onCoreInitFinished() {
                Logger.i("x5内核onCoreInitFinished");
            }

            @Override
            public void onViewInitFinished(boolean b) {
                Logger.i("x5内核初onCoreInitFinished");
            }
        });
    }

}
